package exam.model.dao;

import java.util.List;

import exam.common.util.NullCheckUtil;
import exam.model.entity.TTestEntity;

public class TestDao extends AbstractDao<TTestEntity>{
	
	public TestDao() {
		super(TTestEntity.class);
	}
	
	public List<TTestEntity> selectListTest() {
		return super.selectList("from TTestEntity");
	}
	
	public TTestEntity selectTest(long id) {
		return super.selectByPk(id);
	}
	
	public boolean insertTest(TTestEntity test) {
		if (NullCheckUtil.isNotNull(selectTest(test.getTestId()))) {
			return false;
		}
		super.insert(test);
		return true;
	}
	
	public void updateTest(TTestEntity test) {
			super.update(test);
	}
	
	public boolean deleteTest(long id) {
		if (NullCheckUtil.isNUll(selectByPk(id))) {
			return false;
		}
		super.delete(id);
		return true;
	}
}
